// 配置信息
package bootstrap

import (
	"fmt"

	"gitee.com/copylian/lian-go.git/helper/config"
)

type Config struct {
}

// getDbNames 获取数据库配置
func getDbNames(filename string) []string {
	DbNames := make([]string, 0)

	// 获取数据库文件
	path := fmt.Sprintf("%sconfig/%s/%s.yml", ProjectPath(), DevEnv, filename)

	// 获取yaml文件
	DBConfigs, err := config.GetConfig(path)
	configList, err2 := DBConfigs.Map(filename)
	if err == nil && err2 == nil {
		for DBName, _ := range configList {
			DbNames = append(DbNames, DBName)
		}
	}

	return DbNames
}

// GetConfigByName 通过名称解析yaml
func GetConfigByName(filename string) (configList map[string]interface{}) {
	if filename == "" {
		return configList
	}

	// 文件
	filePath := fmt.Sprintf("%sconfig/%s/%s.yml", ProjectPath(), DevEnv, filename)

	// 获取yaml文件
	cfg, _ := config.GetConfig(filePath)
	configList, _ = cfg.Map(filename)
	return configList
}
